package com.learn.springcloud.zuulreverseproxytzuul.filter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * 查询参数拦截器
 * @Time : 2018/8/13 16:36
 * @Version : 1.0
 */
@Component
public class QueryParamPreFIlter extends ZuulFilter {

    @Override
    public String filterType() {
        return FilterConstants.PRE_TYPE;
    }

    @Override
    public int filterOrder() {
        return 0;
    }

    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() {
        System.out.println("QueryParamFilter...");
        RequestContext currentContext = RequestContext.getCurrentContext();
        HttpServletRequest httpServletRequest = currentContext.getRequest();
        String url = httpServletRequest.getRequestURI();
        System.out.println(url);
        return null;
    }

}
